package com.unknowpupil.alibaba.cloud.oauth2.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;


import java.util.Collection;

/**
 * @author unknowpupil
 * @description
 * @date 2018/12/25 0025 14:51
 */
@Data
@TableName("tb_user")
@NoArgsConstructor
@AllArgsConstructor
@Slf4j
public class TbUser implements UserDetails {

    private static final long serialVersionUID = -2780353800650250964L;

    @TableId(type = IdType.INPUT)
    private Long id;
    @TableField(value = "created_time")
    private String username;
    private String password;
    private String mobile;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return AuthorityUtils.createAuthorityList("ROLE_USER");
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
